package net.aiotos.common.dto;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;


/**
 * 设备属性结构对象
 */
@Data
@NoArgsConstructor
public class DeviceDTO {
    /**
     * description :
     * timestamp : 1619346361
     * gateway_uuid : fac4c9c8609211eb834e000c2918bb69
     * data : 请参考：DataDTO
     * uid : 1
     * on : false
     * name : demo_device
     * config : {"bind":{},"iotosdk.driver":"python/dr_simulator.Simulator","param":{"sub":[]},"parentid":null}
     * device_oid : 52076119
     * tpl_id : 5
     * type :
     */

    @JSONField(name = "description")
    private String description;
    @JSONField(name = "timestamp")
    private Integer timestamp;
    @JSONField(name = "gateway_uuid")
    private String gatewayUuid;
    @JSONField(name = "data")
    private Map<String, DataDTO> data;
    @JSONField(name = "uid")
    private Integer uid;
    @JSONField(name = "on")
    private Boolean on;
    @JSONField(name = "name")
    private String name;
    @JSONField(name = "config")
    private JSONObject config;
    @JSONField(name = "device_oid")
    private String deviceOid;
    @JSONField(name = "tpl_id")
    private Integer tplId;
    @JSONField(name = "type")
    private String type;

    public final <T> T getConfig(Class<T> tClass) {
        return config.toJavaObject(tClass);
    }
}
